<%@page import="application.Facade"%>
<%@page import="application.MembreBean"%>
<%@page import="controleur.ConstantesWeb"%>
<!DOCTYPE html>
<html>   
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Principale</title>
        <link rel="stylesheet" type="text/css" href="<%=ConstantesWeb.CSS_ENTETE%>"/>
    </head>
    <body>
        <%
            Facade f = new Facade();
            MembreBean m;

            m = f.getMembre(request.getCookies());

            if (m == null) {
                out.print("<h1 align=\"center\">Erreur</h1>");
                return;
            }
        %>
        <jsp:include page="<%=ConstantesWeb.PAGE_ENTETE%>"/>

        <h1 align="center">Bienvenue <%=m.getPrenom()%> <%=m.getNomFamille()%></h1>

        <table width="450" align="center" border="1">
            <tr>
                <td align="center" width="220">
                    <FORM name="<%=ConstantesWeb.CMD_IMAGE%>" METHOD="POST" ACTION="./Entree">
                        <input type="hidden" name="idImage" value="<%=m.getIdImage()%>"/>
                        <input type="hidden" name="cmd" value="<%=ConstantesWeb.CMD_IMAGE%>"/>
                                                
                        <a href="#" onclick="document.forms['<%=ConstantesWeb.CMD_IMAGE%>'].submit();">
                        <img src="./<%=ConstantesWeb.PAGE_IMAGE%>?<%=ConstantesWeb.VALEUR_IMAGE_ID%>=<%=m.getIdImage()%>" height="150" width="150" align="center"/>
                    </a>
                    </FORM>                     
                </td>
                <td valign="top">
                    <table align="left" border="0">
                        <tr>
                            <td align="left" colspan="2"><b>Fonctions utilisateurs</b></td>
                        </tr>
                        <tr>
                            <td align="left">
                                <FORM METHOD="POST" ACTION="./Entree">
                                    <input type="hidden" name="cmd" value="<%=ConstantesWeb.CMD_COMPTE%>"/>
                                    <input type="hidden" name="idMembre" value="<%=m.getIdMembre()%>"/>
                                    <button style="width: 150px">Votre compte</button>
                                </FORM>
                            </td>

                        </tr>
                        <tr>
                            <td align="left">
                                <FORM METHOD="POST" ACTION="./Entree">
                                    <input type="hidden" name="cmd" value="<%=ConstantesWeb.CMD_PROFIL%>"/>
                                    <button style="width: 150px">Modifier profil</button>
                                </FORM>
                            </td>
                        </tr>
                        <%
                            if (f.getTypeValeur(m.getIdCompte()).equalsIgnoreCase(ConstantesWeb.COMPTE_ADMIN)) {
                        %>
                        <tr>
                            <td align="left" colspan="2">
                                </br>
                                <b>Fonctions administratives</b>
                            </td>
                        </tr>
                        <tr>
                            <td align="left">
                                <FORM METHOD="POST" ACTION="./Entree">
                                    <input type="hidden" name="cmd" value="<%=ConstantesWeb.CMD_AFFICHER_COMPTES%>"/>
                                    <button style="width: 150px">Tous les comptes</button>
                                </FORM>
                            </td>
                        </tr>
                        <tr>
                            <td align="left">
                                <FORM METHOD="POST" ACTION="./Entree">
                                    <input type="hidden" name="cmd" value="<%=ConstantesWeb.CMD_AFFICHER_MEMBRES%>"/>
                                    <button style="width: 150px">Tous les membres</button>
                                </FORM>
                            </td>
                        </tr>
                        <%
                            }
                        %>
                    </table>
                </td>
            </tr>            
        </table>

    </body>
</html>
